<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="Ver Submissão"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <div style="float: left; width: 50%">
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputText value="Titulo: "/>
                    <h:outputText value="#{submissaoController.selected.titulo}" title="Titulo"/>
                    <h:outputText value="Sumario: "/>
                    <h:inputTextarea disabled="true" cols="50" rows="8" value="#{submissaoController.selected.sumario}" title="Sumario"/>
                    <h:outputText value="Tipo: "/>
                    <h:outputText value="#{submissaoController.selected.tipo}" title="Tipo"/>
                    <h:outputText value="Evento: "/>
                    <h:outputText value="#{submissaoController.selected.evento.titulo}" title="Evento"/>
                    <h:outputText value="Data Registo: "/>
                    <h:outputText value="#{submissaoController.selected.dataRegisto}" title="Data Registo">
                        <f:convertDateTime pattern="dd/MM/yyyy" />
                    </h:outputText>
                    <h:outputText value="Autor"/>
                    <h:outputText value="#{submissaoController.selected.autor}" title="Autor"/>
                </h:panelGrid>
                <br />
                <h:commandLink action="#{submissaoController.destroyAndView}" rendered="#{submissaoController.canDestroy()}" value="Eliminar"/>
                <br />
                <br />
                <h:commandLink action="Edit" rendered="#{eventoController.editarSubmissao(submissaoController.selected)}" value="Editar Submissão"/>
                <br />
                <h:commandLink action="#{submissaoController.prepareList}" rendered="#{eventoController.isAutor()}" value="Suas Submissões" immediate="true"/>
                <br />
                <br />
                <h:commandLink value="Lista Eventos" action="/evento/List" immediate="true" />
            </h:form>
            </div>
            <div style="float: right; width: 50%">
            <h3>Lista de Autores</h3>
            <h:form styleClass="jsfcrud_list_form">
                <h:outputText escape="false" value="Nenhum autor adicionado!" rendered="#{listaAutorController.autores.rowCount == 0}"/>
                <h:panelGroup rendered="#{listaAutorController.autores.rowCount > 0}">
                    <h:dataTable value="#{listaAutorController.autores}" var="autor" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Primeiro Nome"/>
                            </f:facet>
                            <h:outputText value="#{autor.pNome}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Ultimo Nome"/>
                            </f:facet>
                            <h:outputText value="#{autor.uNome}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Empresa"/>
                            </f:facet>
                            <h:outputText value="#{autor.empresa}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="E-Mail"/>
                            </f:facet>
                            <h:outputText value="#{autor.email}"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
                <br />
                <h:commandLink action="/listaAutor/List" rendered="#{eventoController.editarSubmissao(submissaoController.selected)}" value="Editar Lista" />
                <br />
                <br />
                <h3>Lista de Ficheiros</h3>
                <h:outputText escape="false" value="Não existem ficheiros adicionados." rendered="#{ficheiroController.items.rowCount == 0}"/>
                <h:panelGroup rendered="#{ficheiroController.items.rowCount > 0}">
                    <h:outputText value="#{ficheiroController.pagination.pageFirstItem + 1}..#{ficheiroController.pagination.pageLastItem + 1}/#{ficheiroController.pagination.itemsCount}"/>&nbsp;
                    <h:dataTable value="#{ficheiroController.items}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Nome Ficheiro"/>
                            </f:facet>
                            <h:outputText value="#{item.nome}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value=""/>
                            </f:facet>
                            <h:commandLink value="Download">
                                <p:fileDownload value="#{ficheiroController.getFicheiroDownload(item.idFicheiro)}" />
                            </h:commandLink>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value=""/>
                            </f:facet>
                            <h:commandLink action="#{ficheiroController.destroy()}" rendered="#{eventoController.editarSubmissao(submissaoController.selected)}" value="Eliminar"/>
                        </h:column>
                    </h:dataTable>
                </h:panelGroup>
                <br />
                <h:commandLink action="#{ficheiroController.prepareCreate}" rendered="#{eventoController.editarSubmissao(submissaoController.selected)}" value="Novo Ficheiro"/>
            </h:form>
            </div>
        </ui:define>
    </ui:composition>
</html>
